@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
Layout = "_Layout";
}
<body class="layui-anim layui-anim-up">
	<div class="x-nav">
		<span class="layui-breadcrumb">
			<a href="/Admin/Admin/Index">首页</a>
			<a>
				<cite>Banner管理</cite>
			</a>
		</span>
		<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);"
		 title="刷新">
			<i class="layui-icon" style="line-height:30px">ဂ</i>
		</a>
	</div>
	<div class="x-body">
		<table class="layui-table" lay-data="{ url:'/Admin/Comment/GetComment', page:true, id:'comment'}" lay-filter="comment">
			<thead>
				<tr>
					<th lay-data="{field:'', width:'5%', sort: true,type:'numbers'}">ID</th>
					<th lay-data="{field:'UserName', width:'15%'}">用户名</th>
					<th lay-data="{field:'Content', width:'50%'}">评论内容</th>
					<th lay-data="{field:'AddDT' , width:'15%',templet: '<div>{{ HsCms.ToDate(d.AddDT) }}</div>'}">添加时间</th>
					<th lay-data="{field:'' , width:'15%' , templet: '#barDemo'}">操作</th>
				</tr>
			</thead>
		</table>

		<script type="text/html" id="barDemo">
			<a class="layui-btn layui-btn-xs" lay-event="hf">回复</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
        </script>

	</div>
	<script>
		layui.use(['laydate', 'table', 'form', 'layer'], function() {
			var laydate = layui.laydate;
			var table = layui.table;
			var $ = layui.jquery;
			var form = layui.form;
			var layer = layui.layer;


			//监听行工具事件
			table.on('tool(comment)', function(obj) {
				var data = obj.data;
				//console.log(obj)
				if (obj.event === 'del') {
					layer.confirm('真的删除行么', function(index) {

						$.ajax({
							type: "post",
							url: "/Admin/Comment/Del",
							data: {
								id: data.Id
							},
							success: function(result) {
								if (result.state == "ok") {
									layer.msg(result.msg)
								} else {
									layer.msg(result.msg)
								}
							}
						})

						obj.del();

					});
				} else if (obj.event === 'hf') {
					layer.prompt({
							title: '回复评论',
							formType: 2
						}, function(text, index) {
							layer.close(index);
							$.ajax({
							type: "post",
							url: "/Admin/Comment/Up",
							data: {
								id: data.Id,
								huifu:text
							},
							success: function(result) {
								if (result.state == "ok") {
									layer.msg(result.msg)
								} else {
									layer.msg(result.msg)
								}
							}
						})
							
							
							
							
						});
				}
			});
		});
	</script>
</body>
